﻿Imports System.Text.RegularExpressions
'Imports System.Data.OleDb
Public Class Create_new_Advertisement

    Private Sub AngeliaBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AngeliaBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.AngeliaBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.OurDataBaseDataSet)

    End Sub

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'OurDataBaseDataSet.GroupsAggelion' table. You can move, or remove it, as needed.
        Me.GroupsAggelionTableAdapter.Fill(Me.OurDataBaseDataSet.GroupsAggelion)
        'TODO: This line of code loads data into the 'OurDataBaseDataSet.Sent' table. You can move, or remove it, as needed.
        Me.SentTableAdapter.Fill(Me.OurDataBaseDataSet.Sent)
        'TODO: This line of code loads data into the 'OurDataBaseDataSet.Angelia' table. You can move, or remove it, as needed.
        Me.AngeliaTableAdapter.Fill(Me.OurDataBaseDataSet.Angelia)



        TitleComboBox.Enabled = False
        TypesComboBox.Enabled = False
        CityTextBox.Enabled = False
        SalaryTextBox.Enabled = False
        EmployerTextBox.Enabled = False
        QualificationsTextBox.Enabled = False
        JobDescriptionTextBox.Enabled = False
        PhoneTextBox.Enabled = False
        E_mailTextBox.Enabled = False

    End Sub


    Private Sub JobDescriptionLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
        If TitleComboBox.Enabled = False Then
            MessageBox.Show("Add New ", "Error text field")
        End If
        If TitleComboBox.Text = "" Then
            MessageBox.Show("Empty  Title!!  ", "Error text field")
        End If
        If TypesComboBox.Text = "" Then
            MessageBox.Show("Empty  Type !!", "Error Type text field")
        End If
        If CityTextBox.Text = "" Then
            MessageBox.Show("Empty City !!", "Error City text field")
        End If

        If SalaryTextBox.Text = "" Then
            MessageBox.Show("Empty!! Salary ", "Error Salary text field")
        End If
        If EmployerTextBox.Text = "" Then
            MessageBox.Show("Empty!! Employer", "Error Employer text field")
        End If
        If QualificationsTextBox.Text = "" Then
            MessageBox.Show("Empty  Qualifications !!", "Error Qualifications  text field")
        End If
        If PhoneTextBox.Text = "" Then
            MessageBox.Show("Empty  Phone  !!", "Error Phone  text field")
        End If
        Dim objRegExp As Regex = New Regex("^[0-9]{8,}")
        If (objRegExp.IsMatch(PhoneTextBox.Text)) Then

        Else
            MsgBox("Number")
            PhoneTextBox.Select()
        End If
        If JobDescriptionTextBox.Text = "" Then

            MessageBox.Show("Empty  JobDescription!!", "Error JobDescription   text field")
        End If
        If TitleComboBox.Enabled = True And PhoneTextBox.Text <> "" And TitleComboBox.Text <> "" And TypesComboBox.Text <> "" And CityTextBox.Text <> "" And SalaryTextBox.Text <> "" And EmployerTextBox.Text <> "" And QualificationsTextBox.Text <> "" And JobDescriptionTextBox.Text <> "" Then



            Dim dr As DataRow = Me.OurDataBaseDataSet.Angelia.NewRow()



            '8etw times sta pedia 
            dr.Item(1) = TitleComboBox.Text
            dr.Item(2) = TypesComboBox.Text
            dr.Item(3) = CityTextBox.Text
            dr.Item(4) = SalaryTextBox.Text
            dr.Item(5) = QualificationsTextBox.Text
            dr.Item(6) = JobDescriptionTextBox.Text
            dr.Item(7) = EmployerTextBox.Text
            dr.Item(8) = PhoneTextBox.Text
            dr.Item(9) = E_mailTextBox.Text



            'pros8hkh grammhs ston pinaka
            Me.OurDataBaseDataSet.Angelia.Rows.Add(dr)


            Me.Validate()
            Me.AngeliaBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.OurDataBaseDataSet)


            'emfanish mhnumatos epituxous eisagwghs
            MessageBox.Show("Saved", "Insert new row")
        Else
            MessageBox.Show(" No Saved. Fill in all fields ", " No Insert ")
        End If
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub


    Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Remove.Click
        Me.AngeliaBindingSource.RemoveCurrent()
    End Sub

    Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
        Me.AngeliaBindingSource.AddNew()

        TitleComboBox.Enabled = True
        TypesComboBox.Enabled = True
        CityTextBox.Enabled = True
        SalaryTextBox.Enabled = True
        EmployerTextBox.Enabled = True
        QualificationsTextBox.Enabled = True
        JobDescriptionTextBox.Enabled = True
        PhoneTextBox.Enabled = True
        E_mailTextBox.Enabled = True

    End Sub

    Private Sub CreateAd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateAd.Click

    End Sub
End Class